package com.tudouji.common.utils.http;

import com.alibaba.fastjson.JSON;

import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class HarvestAnalysisUtils {
	/**
	 *
	 * @param harvestpost 请求参数
	 * @return
	 */
	public static Map<String, String> analysis(String harvestpost){

		Map<String, String> map=new HashMap<String, String>();
		try {
			String js = URLDecoder.decode(harvestpost, "UTF-8");
			String param = "";
			String token = "";
			Map<String,Object> maps = (Map<String,Object>)JSON.parse(js);
			for(Entry<String, Object> en : maps.entrySet()){
				if (en.getKey().equals("param")) {
					param = (String) en.getValue().toString();
				} else {
					token = (String) en.getValue().toString();
				}
			}
			//获取param
			map.put("param", param);
			map.put("token", token);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return map;
	}

}
